/**
 * CoChall.java
 * Write a program that uses a method printArgs() to print each
 * String in args[] one character at a time with a space after each
 * String except for the final one.
 *
 * Create a subclass of this program that overrides printArgs() to print each
 * String in args[] one character at a time in reverse printing a space after
 * each string except for the last one.
 *
 * @author  John Thomason
 *    Date: Nov 22, 2008
 *  Course: CS222 Java Programming II
 * Seminar: 3
 *  Assign: Coding Challenge
 */

/**
 * CoChall Class
 * - Description
 */
public class CoChall {

  /**
   * Application Entry Point
   * @param args The command line arguments
   */
  public static void main(String[] args) {

    CoChall cc  = new CoChall();
    CoChall scc = new SubCoChall();

    if( args.length > 0 ){
      cc.printArgs(args);
      scc.printArgs(args);
    }

  }//End main()

  public void printArgs(String[] args){
    int a = args.length;
    for(String s: args){
      for(char c: s.toCharArray()){
        System.out.print(c);
      }//for()
      if(--a > 0) System.out.print(" ");
    }//for()
    System.out.println();
  }//printArgs()

}//End CoChall Class

class SubCoChall
extends CoChall {

  @Override
  public void printArgs(String[] args){
    int a = args.length;
    for(String s: args){
      for(int i = s.length() - 1; i >= 0; i--){
        System.out.print(s.charAt(i));
      }//for()
      if(--a > 0) System.out.print(" ");
    }//for()
    System.out.println();
  }//printArgs()

}//End SubCoChall